package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.common.entities.BasePage;
import com.ttg.model.dto.ListConditionsTipsDto;
import com.ttg.model.mapper.ConditionsNameMapper;
import com.ttg.model.pojo.ConditionsName;
import com.ttg.model.vo.ConditionTipsVo;
import com.ttg.model.vo.ConditionVo;
import com.ttg.web.dao.ConditionsNameDao;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZQ
 * @version 1.0
 * @Description
 * @date 2021/1/26 13:26
 */
@Service
public class ConditionsNameDaoImpl extends ServiceImpl<ConditionsNameMapper, ConditionsName> implements ConditionsNameDao {


    @Override
    public List<ConditionVo> findConditionsNameAndDataType() {
        return baseMapper.findConditionsNameAndDataType();
    }

    @Override
    public List<ConditionsName> findConditionsNameByTypeAndSheet(Integer type, Integer sheet) {
        LambdaQueryWrapper<ConditionsName> wrapper = new LambdaQueryWrapper<ConditionsName>();
//        wrapper.eq(ConditionsName::getConditionsNameType,type);
        wrapper.eq(ConditionsName::getConditionsNameSheet,sheet);
        return list(wrapper);
    }

    @Override
    public List<ConditionsName> findConditionsNameByClassId(String classId) {
        LambdaQueryWrapper<ConditionsName> queryWrapper = new LambdaQueryWrapper();
        if(classId!=null){
            queryWrapper.eq(ConditionsName::getClassId,classId);
        }
        queryWrapper.eq(ConditionsName::getShowStatus,0);
        return list(queryWrapper);
    }

    @Override
    public List<ConditionsName> findConditionsNameByClassIdAndSetStatus(String classId) {
        LambdaQueryWrapper<ConditionsName> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(ConditionsName::getClassId,classId);
        queryWrapper.eq(ConditionsName::getSetValueStatus,0);
        return list(queryWrapper);
    }

    @Override
    public BasePage<ConditionTipsVo> listConditionsTips(BasePage<ConditionTipsVo> page, ListConditionsTipsDto reqDto) {
        return baseMapper.listConditionsTips(page,reqDto);
    }
}
